/**
 * <p>Title: LngAndLatUtil.java</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2012</p>
 * <p>Company: shundr</p>
 * @author Wei.Guo
 * @date 2015-5-9
 * @version 1.0
 */
package com.iot.ic.utils;

import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import net.sf.json.JSONObject;
import java.lang.String;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.iot.ic.httpclient.util.AddressComponent;
import com.iot.ic.httpclient.util.BaiduAddressInfo;
import com.iot.ic.httpclient.util.SimpleHttpUtils;




/**
 * <p>Title: LngAndLatUtil</p>
 * <p>Description: 经纬度位置工具类</p>
 * <p>Company: shundr</p>
 * @author lele.chen
 * @date 2016-1-27
 */
public class LngAndLatUtil {	
	private static Log log = LogFactory.getLog(LngAndLatUtil.class);
	  
    public static final String KEY_1 = "cd7gUOKWhpcrwcOmItaTxew7";
    public static final String KEY_2 = "D2EB4663E2B39B43A989F1FA82DF1756";
    public static final String KEY_3 = "C5VEKT96jKtEfyFGvG3mZOHNQ40d067g";
    public static final String Oid = "1990";
  
    /**
    * <p>Title: LngAndLat2City</p>
    * <p>Description: 通过经纬度信息获取City</p>
    * @author Wei.guo
    * @param lng
    * @param lat
    * @return
    * @throws 
    */
    public static BaiduAddressInfo LngAndLat2City(double lat, double lng){   
    	try {  
//       如果有代理，要设置代理，没代理可注释  
//      System.setProperty("http.proxyHost","192.168.1.188");  
//      System.setProperty("http.proxyPort","3128"); 
		Map<String,String> praMap = new HashMap<String,String>();
		String url = "http://api.map.baidu.com/geocoder/v2/?location="
	        	+Double.toString(lng)+","+Double.toString(lat)+"&output=json&pois=1&output=json&ak="+ KEY_3; 
	    String str = SimpleHttpUtils.httpRequest(url, praMap, "GET", "utf-8",null); 
	    if(str != null && !str.equals("") ){  	
	       JSONObject jsonObject = JSONObject.fromObject(str);
	       JSONObject retjson = JSONObject.fromObject(jsonObject.getString("result"));
	       JSONObject addressComponentjson = JSONObject.fromObject(retjson.getString("addressComponent"));
	       BaiduAddressInfo addressInfo = new BaiduAddressInfo();
	       AddressComponent addressComponent =(AddressComponent) JSONObject.toBean(addressComponentjson, AddressComponent.class);
	       Map retMap = new HashMap();
	       retMap.put("addressComponent", addressComponent);
	       retMap.put("formatted_address", retjson.getString("formatted_address"));
	       addressInfo.setStatus(jsonObject.getString("status"));
	       addressInfo.setResult(retMap);
	       return addressInfo;  
            }  
        }catch (Exception e) {  
            e.printStackTrace();  
            log.error(lng + "," + lat);
        } 
		return null;  
    }  
      
    /**  
     * 返回输入地址的经纬度坐标 
     *  lng(经度),lat(纬度) 
     */  
    public static Map<String,String> getGeocoderLatitude(String address){   
        try {  
            //将地址转换成utf-8的16进制  
            address = URLEncoder.encode(address, "UTF-8");  
//       如果有代理，要设置代理，没代理可注释  
//      System.setProperty("http.proxyHost","192.168.1.188");  
//      System.setProperty("http.proxyPort","3128");  
            //URL tirc = new URL("http://api.map.baidu.com/geocoder?address="+ address +"&output=json&key="+ KEY_1);  
            
            Map<String,String> map1 = new HashMap<String,String>();
        	String url = "http://api.map.baidu.com/geocoder?address="+ address +"&output=json&key="+ KEY_3;
            String str = SimpleHttpUtils.httpRequest(url, map1, "GET", "utf-8",null);      
//            URL tirc = new URL("http://api.map.baidu.com/geoconv/v1/?coords=120.272032,36.266380&from=1&to=5&ak="+ KEY_1);             
            System.out.println(str);
            Map<String,String> map = null;  
            if(str != null && !str.equals("") ){  
                int lngStart = str.indexOf("lng\":");  
                int lngEnd = str.indexOf(",\"lat");  
                int latEnd = str.indexOf("},\"precise");  
                if(lngStart > 0 && lngEnd > 0 && latEnd > 0){  
                    String lng = str.substring(lngStart+5, lngEnd);  
                    String lat = str.substring(lngEnd+7, latEnd);  
                    map = new HashMap<String,String>();  
                    map.put("lng", lng);  
                    map.put("lat", lat);  
                    return map;  
                }  
            }  
        }catch (Exception e) {  
            e.printStackTrace();  
        }
        return null;  
    }  
    
    /**  
     * 将硬件GPS经纬度转换为百度经纬度
     * lng(经度),lat(纬度) 
     */  
    public static Map<String,String> gpsCodes2BaiduCodes(double lat, double lng){    
        try { 
        	
        	Map<String,String> praMap = new HashMap<String,String>();
        	String url = "http://api.map.baidu.com/geoconv/v1/?coords="+Double.toString(lng)+","+Double.toString(lat)+"&from=1&to=5&ak="+ KEY_3;
            String str = SimpleHttpUtils.httpRequest(url, praMap, "GET", "utf-8",null);            
//            URL tirc = new URL("http://api.gpsspg.com/convert/latlng/?oid=" + Oid +"&key="+ KEY_2 +"&from=0&to=2&latlng="+Double.toString(lat)+","+Double.toString(lng));
            System.out.println(str);
            Map<String,String> map = null;  
            if(str != null && !str.equals("") ){  
                int latStart = str.indexOf("x\":");  
                int latEnd = str.indexOf(",\"y");  
                int lngEnd = str.indexOf("}]");  
                if(latStart > 0 && lngEnd > 0 && latEnd > 0){  
                    String baiduLng = str.substring(latStart+3, latEnd);  
                    String baiduLat = str.substring(latEnd+5, lngEnd);
                    map = new HashMap<String,String>();  
                    map.put("lng", baiduLng);  
                    map.put("lat", baiduLat);
                    return map; 
                }  
            }  
        }catch (Exception e) {  
            e.printStackTrace();  
        } 
        return null;   
    }  
    /**
    * <p>Title: gpsCodes2Loc</p>
    * <p>Description: 根据GPS经纬度获得具体地理位置</p>
    * @author lele.chen
    * @param lat
    * @param lng
    * @return
    */
    public static String gpsCodes2Loc(double lat, double lng){    
        try {
        	Map<String,String> praMap = new HashMap<String,String>();
        	String url = "http://api.map.baidu.com/geoconv/v1/?coords="+Double.toString(lng)+","+Double.toString(lat)+"&from=1&to=5&ak="+ KEY_3;
            String str = SimpleHttpUtils.httpRequest(url, praMap, "GET", "utf-8",null);
            if(str != null && !str.equals("") ){  
                int latStart = str.indexOf("x\":");  
                int latEnd = str.indexOf(",\"y");  
                int lngEnd = str.indexOf("}]"); 
                if(latStart > 0 && lngEnd > 0 && latEnd > 0){  
                    String baiduLat = str.substring(latStart+3, latEnd);  
                    String baiduLng = str.substring(latEnd+5, lngEnd);
                    BaiduAddressInfo baiduaddressinfo = LngAndLat2City(Double.parseDouble(baiduLat),Double.parseDouble(baiduLng));
                    return baiduaddressinfo.getResult().get("formatted_address").toString(); 
                }  
            }  
        }catch (Exception e) {  
            e.printStackTrace();  
        } 
        return null;   
    }  
    /**  
     * 根据Lac和cellID获得基站百度坐标
     * lac(位置区编码),cellID(小区基站号) 
     */  
    public static Map<String,String> gprsCodeToBaiduCodes(Integer lac, Integer cell){   
        try {  
        	Map<String,String> praMap = new HashMap<String,String>();
        	String url = "http://api.cellocation.com/cell/?mcc=460&mnc=0&lac="+lac+"&ci="+cell+"&output=json&coord=bd09";
            String str = SimpleHttpUtils.httpRequest(url, praMap, "GET", "utf-8",null);
            Map<String,String> map = null;  
            if(str != null && !str.equals("") ){  
                int latStart = str.indexOf("lat\":");  
                int latEnd = str.indexOf(", \"lon");  
                int lngEnd = str.indexOf(", \"ra");  
                if(latStart > 0 && lngEnd > 0 && latEnd > 0){  
                    String gprsLat = str.substring(latStart+6, latEnd-1);  
                    String gprsLng = str.substring(latEnd+9, lngEnd-1);
                    map = new HashMap<String,String>();  
                    map.put("lng", gprsLng);  
                    map.put("lat", gprsLat);
                    return map; 
                }  
            } 
        }catch (Exception e) {  
            e.printStackTrace();  
        }  
        return null;   
    } 
    /**
    * <p>Title: gprsCodeToLoc</p>
    * <p>Description:根据GPRS经纬度获得具体地理位置 </p>
    * @author lele.chen
    * @param lac
    * @param cell
    * @return
    */
    public static String gprsCodeToLoc(Integer lac, Integer cell){   
        try {   	
        	Map<String,String> praMap = new HashMap<String,String>();
        	String url = "http://api.cellocation.com/cell/?mcc=460&mnc=0&lac="+lac+"&ci="+cell+"&output=json";
            String str = SimpleHttpUtils.httpRequest(url, praMap, "GET", "utf-8",null);
            Map<String,String> map = null;  
            if(str != null && !str.equals("") ){  
                int adressStart = str.indexOf("address\":");  
                int adressEnd = str.indexOf(";");    
                if(adressStart > 0 && adressEnd > 0){  
                    String gprsAddress = str.substring(adressStart+10, adressEnd);
                    return gprsAddress; 
                }  
            } 
        }catch (Exception e) {  
            e.printStackTrace();  
        } 
        return null;   
    } 
    public static void main(String args[]){  
    	System.out.println(LngAndLat2City(36.26629,120.27248));
//        Map<String, String> json = LngAndLatUtil.getGeocoderLatitude("福建泉州安溪湖头");  
//        System.out.println("lng : "+json.get("lng"));  
//        System.out.println("lat : "+json.get("lat")); 
    	/*double[] locStrings = {36.84986,118.069609,123.45,111.44,39.9088,116.43458,39.913099,116.344491,39.91054,116.440125,116.256352,39.857416,40.050181,116.301178,116.016477,39.730046,116.645264,39.894623,40.177526,116.647914,40.067998,116.345491,116.406605,39.760179,116.882073,38.929439,38.686114,116.893343,39.074444,117.189994,117.305742,39.205857,117.042632,39.158701,117.310615,39.039333,117.105661,39.202397,117.055785,39.41351,39.459776,117.43298,117.743012,39.011329,38.064342,114.538759,38.066624,114.504412,37.977942,114.661125,114.595336,37.955402,37.777469,114.562392,37.702514,114.806353,38.049408,114.926838,37.976234,114.506428,39.314953,118.337537,39.641957,118.094591,118.115207,39.533517,117.944489,39.61073,39.334511,118.506074,39.406493,118.871205,40.032878,119.764599,113.707867,36.575298,36.28078,115.182074,36.665972,113.801278,114.671448,36.525496,115.179792,36.556175,36.57689,115.24477,114.271529,36.585828,114.203155,37.172038,37.013129,114.711149,37.620235,114.946382,36.987451,115.167939,37.073838,115.06014,115.433517,37.091471,37.056915,115.66263,36.891935,115.69847,37.138753,115.586751,115.530917,38.815709,114.750937,39.061471,38.922794,115.857664,38.365273,115.628501,115.147863,38.51886,41.980264,117.741363,38.581405,116.820163,116.963126,38.260032,38.413416,116.799771,37.938534,116.596561,117.415931,38.218521,37.857919,116.941886,37.59968,116.439338,38.232928,116.120747,38.078361,116.644172,117.154732,38.60283,38.411793,116.544789,116.683232,39.50366,38.711423,116.558993,116.694948,38.947674,37.723318,115.730068,37.438465,116.228747,37.796411,112.651144,112.503005,38.008155,112.49871,37.83799,112.48838,37.759411,112.341131,37.596983,39.441574,114.228387,113.141288,36.3643,112.818435,36.328368,113.375584,36.46515,113.226812,36.346393,35.74558,112.03693,112.783485,37.614087,37.31497,113.185138,112.555374,37.515011,37.366174,112.301115,37.249408,112.205634,37.113123,112.008014,35.14137,110.799575,35.417511,110.8477,35.521118,110.928551,35.4762,111.46999,111.581473,36.151015,35.691624,111.503411,35.713724,111.663723,111.700373,36.356578,111.989154,36.16269,112.482735,36.254523,35.609337,111.324826,37.514891,111.131456,112.107339,37.425552,112.164068,37.510464,37.478557,111.034563,111.49001,37.179653,111.85504,37.259233,40.750018,111.311127,40.571374,110.213721,41.791253,123.395753,41.913739,123.455868,41.78531,123.282045,41.649349,122.960408,41.903039,123.899774,42.304121,125.264066,41.097341,121.355396,41.202111,122.058996,41.124246,122.070922,41.264649,122.001091,40.753237,120.780803,40.206967,120.106646,40.674604,120.714719,43.64862,126.369793,43.922871,126.902211,45.314094,124.952439,43.539934,127.867491,44.586488,129.651672,44.444198,129.491721,43.926617,129.054558,31.290126,121.341503,121.389602,31.035543,121.41051,31.353885,121.320976,31.348642,31.205714,121.584828,121.300844,31.153739,121.109617,31.192826,31.313746,120.629736,32.116806,118.790352,32.06577,118.63588,32.117005,118.863885,32.043151,118.933106,32.501135,118.681882,31.93376,120.253258,120.321018,31.610448,120.31945,31.550784,120.295842,31.624138,120.324556,31.635762,31.623091,120.233692,120.386569,31.53426,31.904736,120.250165,119.67044,31.609828,34.312992,117.759866,34.302603,117.243265,34.266896,117.205032,117.315875,34.367572,117.119103,34.150951,34.671865,116.683899,116.809821,34.91854,117.814387,33.765996,118.46305,34.365493,118.013392,34.348559,31.813981,120.027406,119.871417,31.774239,31.810039,119.964767,31.785308,119.840865,31.633303,119.288657,31.372291,120.559076,120.449206,31.383588,31.311074,120.644331,31.353449,120.621766,120.584387,31.606209,120.466507,31.978312,121.022187,31.223477,30.891021,120.688733,120.972837,32.053082,33.775027,119.257162,120.743456,32.332087,34.757317,119.174455,34.634352,119.085762,34.450161,119.18425,34.712785,119.088896,34.541351,119.093379,34.240285,119.231052,34.09951,119.275368,33.584491,118.997574,33.279501,118.900062,33.667988,118.986625,33.375276,118.922981,33.873205,119.229205,33.120451,118.868631,32.955668,118.847498,120.300794,33.380462,119.847546,34.401498,119.914933,34.003718,33.796179,119.834818,120.363119,34.008934,32.840463,120.31021,33.788368,119.249016,119.333168,32.419588,33.288511,119.341846,32.758851,119.449506,119.673991,32.199497,32.149179,119.424849,31.973452,119.29895,32.252099,119.918635,120.139758,32.743678,31.976546,120.315254,32.135013,119.923011,120.085577,32.582254,33.825446,118.291466,33.937182,118.348549,34.169923,118.706027,118.675383,33.761604,118.313122,33.636764,120.207759,30.333116,30.291815,120.386616,120.202726,30.394682,120.21695,30.173334,120.317124,30.2084,120.267567,30.426247,30.205986,119.692431,29.93217,121.954528,29.917002,121.611047,29.958553,121.784312,30.040441,121.602768,121.327607,30.353899,120.698472,27.775305,30.735586,120.886413,30.870841,120.677668,30.539217,121.07601,120.411077,30.37572,30.774804,121.055708,120.39097,30.889745,29.307294,120.124871,28.953256,118.889178,28.606155,121.274311,31.851742,117.337914,31.759762,117.236016,117.312105,31.850805,31.971802,117.325119,31.923016,117.593813,117.175529,31.512027,33.293337,117.050905,32.622925,117.148031,33.97752,116.797696,116.797771,33.876926,116.784692,33.829391,30.934187,117.309944,117.312183,31.854478,118.431794,32.424577,117.847963,31.993323,32.578548,117.265245,117.722027,32.932967,32.94552,118.86525,116.996511,33.611044,117.058148,34.136992,33.751137,117.541207,33.649221,118.094367,115.854593,33.936526,30.723327,118.562701,30.601058,118.968021,28.624529,115.871172,28.589641,115.793768,28.437931,117.967792,36.660614,117.017748,36.642615,116.934928,36.655224,116.979881,36.684806,117.023786,36.486242,117.019737,116.779185,36.567435,116.441527,36.277305,117.155808,36.983298,117.175393,37.193316,117.571327,36.869707,36.266167,120.271966,36.086559,120.373896,36.255093,120.262087,36.090397,120.124075,36.1528,120.484921,36.172219,120.373295,36.266623,120.277256,36.233647,120.253343,36.394685,120.271213,36.60746,120.107803,119.983384,36.053717,120.551481,36.66417,36.771351,118.071068,117.978359,36.748729,36.836829,118.043327,36.526277,117.878198,36.804856,118.320256,117.933627,36.746218,36.964441,118.058787,117.861361,37.205177,118.058612,36.201343,36.65565,116.992627,117.285444,34.831338,117.560043,34.735995,117.432574,34.5559,117.460027,35.107595,117.115936,35.152841,37.455379,118.542356,37.670908,118.418111,118.489373,37.01545,121.343002,37.558392,37.555302,121.077492,121.493253,37.285287,121.421466,37.455817,120.525155,36.868127,120.571795,37.60485,120.738318,36.976639,119.873015,37.019614,37.637834,120.721841,120.344274,37.436703,120.919408,37.36555,36.764192,121.157126,36.707976,119.035046,119.178568,37.065993,36.607591,119.345786,36.690941,119.107075,118.484149,36.197429,36.709414,118.858311,36.758977,118.55099,119.397529,35.983044,36.756051,118.794118,36.570186,119.363379,36.406126,119.724917,36.518179,119.551317,116.626204,35.431038,116.700597,35.440273,116.621679,35.304155,116.205455,35.080067,116.347947,35.379208,35.719995,116.521683,117.514549,35.633006,116.168284,35.710392,116.873362,35.6209,116.852884,35.624043,117.086194,35.391059,36.198029,117.203502,117.093244,36.177337,35.907998,117.080583,116.549873,35.959682,35.878693,117.677014,116.575422,36.102674,122.042708,37.503819,122.499066,37.176439,36.903936,121.510636,35.553285,119.533443,35.214409,119.337667,119.152987,35.92026,118.821938,35.558772,36.317941,117.494994,36.029801,117.818688,35.110539,118.268249,35.059313,118.321427,118.307969,35.004018,36.818544,118.071263,118.596591,35.599592,34.611618,118.358494,118.900438,36.043911,118.174048,34.874017,118.263066,35.297707,117.817796,35.427806,119.107242,35.123063,35.792814,118.198636,118.62466,34.959018,116.403167,37.452396,116.565405,37.34941,116.826104,37.695709,117.445012,37.700842,37.322452,116.969573,116.960437,36.847783,37.152842,116.318057,36.945417,116.03662,37.326813,116.063682,117.146756,37.634026,116.427452,36.730836,115.9645,36.517301,115.837382,36.150518,115.670981,36.238173,116.193638,36.527853,116.241994,36.338515,115.675918,36.506719,36.859044,116.213457,36.905416,115.882952,37.007509,118.164762,117.903303,37.547144,117.689782,37.305846,117.609766,37.759142,37.636114,118.098954,118.180457,37.159366,117.645934,36.896393,115.554455,35.228354,115.147085,34.99326,116.308549,34.856586,116.128409,35.079307,116.051115,35.161876,115.897979,35.471228,115.551279,35.120351,113.537958,34.862681,113.797963,34.727537,34.847678,113.647869,113.619422,34.830568,114.042889,34.83986,113.001411,34.683038,113.490241,34.730251,113.411677,34.457907,113.598544,34.338796,114.742703,34.453407,114.580445,34.431863,114.249048,34.405421,115.137873,34.992026,115.022427,34.949941,112.333356,34.718979,112.416864,34.600834,112.521475,34.462012,113.326248,33.739378,113.266567,33.680418,113.262449,33.661268,113.250873,33.979385,113.497715,33.285016,114.710841,35.607411,113.925063,35.271232,35.31046,113.860446,113.814142,35.258366,113.778452,35.030169,35.086509,114.522402,35.130206,114.7017,113.183481,35.206521,35.031889,112.862216,115.314712,35.842269,36.153122,115.480568,35.798333,115.410547,36.027268,116.053901,115.133444,35.793074,34.099354,114.154926,114.015741,34.192272,113.95542,33.535417,113.788836,33.674697,114.057151,33.565968,113.784057,33.515507,112.601965,32.965779,112.496154,33.017484,33.259836,112.967965,111.782329,32.724437,113.498702,32.354337,112.128106,32.502695,115.746812,34.576733,115.53572,34.351357,115.390228,34.120589,115.721977,34.507063,34.115577,116.058935,32.133955,114.13944,114.294724,31.936831,32.121599,114.925026,31.6924,114.916133,32.594844,114.861799,114.716626,33.597578,33.649314,114.533459,114.355242,33.58933,115.329302,33.308333,114.931343,33.770003,34.055007,114.833756,33.116356,114.79858,33.007597,114.122682,32.977712,114.759691,32.603877,114.407268,114.129267,32.624239,33.046481,114.165772,33.14146,113.993296,114.955899,32.777604,113.328705,31.837518,114.275488,30.633159,30.50061,114.418125,114.046802,30.700027,30.928981,114.901442,115.048765,30.255726,115.167118,30.205652,30.19632,114.934763,30.653362,111.412783,30.565708,111.417594,111.837979,30.804452,32.237416,112.094885,31.562548,112.284626,30.232224,114.982058,112.305465,30.912195,112.341056,31.440709,30.341753,112.285653,30.378666,112.205621,30.020502,112.134999,113.04943,29.870453,113.140921,29.744375,30.553551,115.032748,30.690624,114.913478,30.483932,115.065989,31.364094,114.92201,114.319385,29.904575,29.175393,113.783086,29.329124,113.799653,29.564887,113.717124,28.21038,113.032347,28.229837,113.003367,28.169994,113.03976,28.233176,113.00251,27.245983,113.469962,112.431046,27.759735,29.382457,113.133259,29.540035,112.776433,29.405751,112.407486,29.32723,113.384535,28.917452,111.730876,28.914631,111.760947,29.34831,112.171381,29.451938,111.772718,28.59803,111.075729,28.587821,112.524882,28.475903,110.604551,28.26964,109.932798,28.050146,109.610462,23.10254,113.23856,22.509816,113.886664,23.420817,116.729616,23.421008,116.729681,23.390482,116.687741,22.919612,113.05453,110.357012,21.255558,25.631765,110.190631,29.504218,106.581385,30.715404,104.03757,104.139508,30.809808,103.951109,30.781223,103.904303,31.011365,104.517891,31.337739,104.302608,30.951549,104.668793,31.478189,104.800139,31.667176,105.724462,32.364731,106.050501,32.707743,105.52076,32.288899,106.730704,26.567774,106.808504,26.551473,106.625098,26.576751,26.853438,106.747898,26.556319,106.494637,106.089566,26.330165,106.504288,26.352434,25.866547,105.244632,107.947184,26.555122,27.074711,108.745119,107.269863,26.3131,102.837496,24.988022,102.8868,24.950763,103.712621,25.472527,102.98899,24.693958,108.517135,34.281411,110.300429,33.702341,110.956811,33.478461,103.932795,36.054635,103.28537,36.176994,103.406275,36.490363,38.528148,102.227395,102.103428,38.202143,105.791012,34.463548,105.888083,34.476532,34.87408,105.681526,105.247128,34.752166,103.015849,37.08885,99.350786,39.299891,101.354661,38.606105,98.455049,39.722597,95.655016,40.754852,38.12409,106.632042,37.99494,106.184765,38.00656,106.146253,36.457036,106.134912,95.135779,41.80646,39.535158,78.087758,81.259918,43.971144,44.388553,84.628151,5e-324,5e-324,5e-324,5e-324};
    	for(int i=0;i<locStrings.length;i = i+2){
    		if(locStrings[i]<=1){
    			continue;
    		}else{
    			if(locStrings[i] > locStrings[i+1]){
        			double temp = locStrings[i];
        			locStrings[i] = locStrings[i+1];
        			locStrings[i+1] = temp;
        		}
        		BaiduAddressInfo af = LngAndLatUtil.LngAndLat2City(locStrings[i+1],locStrings[i]);
        		AddressComponent aComponent = (AddressComponent) af.getResult().get("addressComponent");
        		if("".equals(aComponent.getCity()) || aComponent.getCity() == null){
        			System.out.println("---"+aComponent.getCity()); 
        		}
        		
    		}
    		
    	}*/
  //  	LngAndLat2City(120.272032,36.266380);
//   	    Map<String,String> map =gpsCodes2BaiduCodes(120.272032,36.266380);
//   	    BaiduAddressInfo baiduaddressinfo = LngAndLat2City(Double.valueOf(map.get("lat")),Double.valueOf(map.get("lng")));
//    	Map<String, Object> amp = baiduaddressinfo.getResult();
//    	System.out.println(amp.get("formatted_address"));
//    	
//    	
    	
//    	gprsCodeToLoc(Integer.parseInt("542b",16),Integer.parseInt("1008",16));
   	        	
//
    	Map<String,String> map = gprsCodeToBaiduCodes(21547,4104);
    	System.out.println(map.get("lng"));
    	System.out.println(map.get("lat"));
   	    BaiduAddressInfo baiduaddressinfo = LngAndLat2City(Double.valueOf(map.get("lng")),Double.valueOf(map.get("lat")));
    	Map<String, Object> amp = baiduaddressinfo.getResult();
    	System.out.println(amp.get("formatted_address"));
    	
    	//String loc = gprsCodeToLoc(Integer.parseInt("542b",16),Integer.parseInt("1008",16));
    	//System.out.println(loc);
  //  	BaiduAddressInfo baiduaddressinfo2 = LngAndLat2City(120.28361842202,36.272419360478);
    //	Map<String, Object> amp2 = baiduaddressinfo2.getResult();
   	//    System.out.println(amp2.get("formatted_address"));
//    	getGeocoderLatitude("山东省青岛市城阳区智力岛东路");
    }  
}